package com.gee.lowui;

import javax.microedition.lcdui.*;

public class Label extends GControl
{
	private Image imgcontrol = null;

	public int fontColor = 0;

	public static byte //
			LABEL_FULL = 0,//			
			LABEL_TEXT = 1,//
			LABEL_IMAGE = 2;//

	public Label(String str)
	{
		controlString = str;
		fontColor = charColor[0];
		initializePostion();
	}

	public Label(Image img, String str)
	{
		setImage(img);
		controlString = str;
		fontColor = charColor[0];
		initializePostion();
	}

	public Label(Image img)
	{
		setImage(img);
		fontColor = charColor[0];
		initializePostion();
	}

	public void setcontrolString(String s)
	{
		controlString = s;
		initializePostion();
	}

	public void setImage(Image img)
	{
		imgcontrol = img;
		controlW = img.getWidth();
		controlH = img.getHeight();
		initializePostion();
	}

	public void drawControl(Graphics g)
	{
		if (!isView)
		{
			return;
		}
		g.setFont(fontstyle);
		g.setColor(fontColor);
		if (imgcontrol == null)
		{
			g.drawString(controlString, x, y, anchor);
		}
		else
		{
			g.drawImage(imgcontrol, controlX, controlY, Graphics.TOP | Graphics.LEFT);
			if (controlString.length() > 0)
			{
				g.drawString(controlString, controlX + (controlW >> 1), controlY + (controlH >> 1) - (FONT_HEIGHT >> 1), Graphics.HCENTER | Graphics.TOP);
			}
		}
	}

	public int getControlType()
	{
		return GControl.CONTROL_LABEL;
	}
}